<template>
  <div class="app-container">
    <div style="padding:10px">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-button v-hasPermi="'raffle/save'" icon="el-icon-plus" size="small" type="primary"
            @click="DialogsaveWays">添加运费模板</el-button>
        </el-col>
        <el-col :span="8" style="float: right">
          <div class="right-panel el-button-group">
            <el-button class="" icon="el-icon-refresh" size="mini" @click="resetting"></el-button>
            <el-dropdown trigger="click" :hide-on-click="false">
              <span class="el-dropdown-link">
                <el-button class="" icon="el-icon-s-operation" size="mini"></el-button>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item v-for="fruit in allTableThead" :key="fruit">
                  <el-checkbox v-model="checkboxTableThead" :label="fruit">{{
                    tableTheadOptions[fruit].label
                  }}</el-checkbox>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-col>
      </el-row>

      <el-col class="marginTop">
        <el-table v-loading="loading" highlight-current-row :data="dataList" :header-cell-style="{
            'background-color': '#f3f8fe',
            color: '#606266',
            height: '50px',
          }" style="width: 100%">
          <el-table-column v-for="fruit in tableThead" :key="fruit" :label="tableTheadOptions[fruit].label"
            min-width="80" align="center">
            <template slot-scope="scope">
              <div v-if="fruit == 'is_delivery_free'">
                <span v-if="scope.row.is_delivery_free == 0" style="color: #ff4949;">关闭</span>
                <span v-if="scope.row.is_delivery_free == 1" style="color: #13ce66;">启用</span>
              </div>
              <div v-else-if="fruit == 'is_delivery_not'">
                <span v-if="scope.row.is_delivery_not == 0" style="color: #ff4949;">关闭</span>
                <span v-if="scope.row.is_delivery_not == 1" style="color: #13ce66;">启用</span>
              </div>
              <div v-else-if="fruit == 'type'">
                <span v-if="scope.row.type == 1">按件数(件)</span>
                <span v-if="scope.row.type == 2">按重量(kg)</span>
                <span v-if="scope.row.type == 3">按体积(m³)</span>
              </div>
              <div v-else>
                <el-tooltip placement="top-start" :content="scope.row[fruit] + ''">
                  <div class="one_line_hidden">
                    {{ scope.row[fruit] ? scope.row[fruit] : "-" }}
                  </div>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column fixed="right" width="240" prop="address" label="操作" align="center">
            <template slot-scope="scope">
              <el-button v-hasPermi="'raffle/edit'" style="margin: 5px" type="text" size="mini"
                @click="DialogsaveWay(scope.row.id)">
                编辑
              </el-button>
              <el-popconfirm title="确定删除此模板吗？" @confirm="deleteCoupon(scope.row)">
                <el-button v-hasPermi="'raffle/del'" style="margin: 5px" type="text" size="mini" slot="reference">
                  删除
                </el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col style="text-align: right">
        <pagination v-show="total > 0" :total="total" :page.sync="searchForm.page" :limit.sync="searchForm.count"
          @pagination="getListWay" />
      </el-col>
    </div>
    <!--  -->
    <el-drawer :modal-append-to-body="false" :append-to-body="true" title="运费模版" size="70%" :withHeader="false"
      :visible.sync="drawerfregit" @close="closing_fregit" :show-close="true">
      <div class="drawerTitle" style="margin-bottom: 20px;">
        <span>运费模版</span>
        <div class="close" @click="closing_fregit">
          <i class="el-icon-close" style="font-size: 24px;"></i>
        </div>
      </div>
      <!--  -->
      <div v-loading="loadings">
        <el-scrollbar wrap-style="overflow-x:hidden;" style="height: calc(100vh - 180px)">
          <el-form :model="basicForm" :rules="basicRules" ref="basicForm" label-width="140px" class="demo-ruleForm">
            <el-row>
              <el-col :span="24">
                <el-col :span="10">
                  <el-form-item label-position="top" label="模板名称" prop="name">
                    <el-input clearable placeholder="请输入模板名称" v-model="basicForm.name" maxlength="20"
                      show-word-limit></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="排序" prop="weight">
                    <el-input clearable @focus="weightFocus(basicForm)" @blur="weightBlur(basicForm)"
                      placeholder="请输入排序(值越大越靠前)" v-model="basicForm.weight" maxlength="20" show-word-limit></el-input>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="24">
                <el-form-item label="计费方式" prop="type">
                  <el-radio-group v-model="basicForm.type">
                    <el-radio :label="1">按件数(件)</el-radio>
                    <el-radio :label="2">按重量(kg)</el-radio>
                    <el-radio :label="3">按体积(m³)</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <div class="informationTitleView">
                  <div class="leftBox" style="padding-left: 10px;">
                    <div class="leftborder"></div>
                    <div class="text">配送地区</div>
                  </div>
                  <div class="right"></div>
                </div>
              </el-col>

              <!-- <el-col :span="24"> -->
              <el-col :span="22" v-for="(
                        delivery_arrive, index
                      ) in basicForm.delivery_arrive" :key="index" style="margin-left: 30px;">
                <el-col :span="4" style="margin: 0 5px">
                  <el-form-item label-width="5px" :prop="'delivery_arrive.' + index + '.region_ids'" :rules="{
                            required: index == 0 ? false : true,
                            validator: index == 0 ? region_idss : region_ids,
                            trigger: 'change',
                          }">
                    <div>地区</div>
                    <el-cascader :placeholder="index == 0 ? '默认全国' : '请选择地区'"
                      @change="region_ids_jsonWay(delivery_arrive)" v-model="delivery_arrive.region_ids_json"
                      style="width: 100%" :options="regionList" collapse-tags :show-all-levels="false" :props="{
                              expandTrigger: 'hover',
                              multiple: true,
                              value: 'id',
                              label: 'name',
                              children: 'children',
                            }" clearable />
                  </el-form-item>
                </el-col>
                <el-col :span="4" style="margin: 0 5px">
                  <el-form-item label=" " label-width="5px" :rules="{
                            required: true,
                            validator: first_num,
                            trigger: 'change',
                          }" :prop="'delivery_arrive.' + index + '.first_num'">
                    <div>(首件/体积/重量)数量</div>
                    <el-input clearable @focus="Focus(delivery_arrive, 'first_num')"
                      @blur="Blur(delivery_arrive, 'first_num')" placeholder="(首件/体积/重量)数量"
                      v-model="delivery_arrive.first_num" maxlength="7" show-word-limit></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="4" style="margin: 0 5px">
                  <el-form-item label=" " label-width="5px" :rules="{
                            required: true,
                            validator: first_price,
                            trigger: 'change',
                          }" :prop="'delivery_arrive.' + index + '.first_price'">
                    <div>(首件/体积/重量)价格(元)</div>
                    <el-input clearable @focus="Focus(delivery_arrive, 'first_price')"
                      @blur="Blur(delivery_arrive, 'first_price')" placeholder="首件/体积/重量)价格(元)"
                      v-model="delivery_arrive.first_price" maxlength="7" show-word-limit></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="4" style="margin: 0 5px">
                  <el-form-item label=" " label-width="5px" :rules="{
                            required: true,
                            validator: first_num,
                            trigger: 'change',
                          }" :prop="'delivery_arrive.' + index + '.renew_num'">
                    <div>续件数量</div>
                    <el-input clearable @focus="Focus(delivery_arrive, 'renew_num')"
                      @blur="Blur(delivery_arrive, 'renew_num')" placeholder="续件数量" v-model="delivery_arrive.renew_num"
                      maxlength="7" show-word-limit></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="3" style="margin: 0 5px">
                  <el-form-item label=" " label-width="5px" :rules="{
                            required: true,
                            validator: first_price,
                            trigger: 'change',
                          }" :prop="'delivery_arrive.' + index + '.renew_price'">
                    <div>续件价格</div>
                    <el-input clearable @focus="Focus(delivery_arrive, 'renew_price')"
                      @blur="Blur(delivery_arrive, 'renew_price')" placeholder="续件价格(元)"
                      v-model="delivery_arrive.renew_price" maxlength="7" show-word-limit></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="basicForm.delivery_arrive.length > 1" :span="1"
                  style="text-align: center;margin-top: 10px;">
                  <div>增/减</div>
                  <el-button type="danger" @click="delDistributionWay(delivery_arrive)" icon="el-icon-minus"
                    circle></el-button>
                </el-col>
              </el-col>
              <div style="margin-left: 38px;">
                <el-button @click="addDistributionWay" type="primary" icon="el-icon-plus">添加配送区域</el-button>
              </div>
              <el-col :span="24">
                <div class="informationTitleView">
                  <div class="leftBox" style="padding-left: 10px;">
                    <div class="leftborder"></div>
                    <div class="text">包邮地区</div>
                  </div>
                  <div class="right"></div>
                </div>
                <el-col :span="24">
                  <el-form-item label="是否包邮" prop="is_delivery_free">
                    <el-radio-group @change="is_delivery_freeWay" v-model="basicForm.is_delivery_free">
                      <el-radio :label="0">关闭</el-radio>
                      <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-col v-if="basicForm.is_delivery_free !== 0" :span="22"
                    v-for="(delivery_free, index) in basicForm.delivery_free" :key="index" style="margin-left: 30px;">
                    <el-col :span="5" style="margin: 0 5px">
                      <el-form-item label=" " label-width="5px" :prop="'delivery_free.' + index + '.region_ids'" :rules="{
                            required: true,
                            validator: region_ids,
                            trigger: 'change',
                          }">
                        <div>地区</div>
                        <el-cascader @change="region_ids_jsonWay(delivery_free)" v-model="delivery_free.region_ids_json"
                          style="width: 100%" :options="regionList" collapse-tags :show-all-levels="false" :props="{
                              expandTrigger: 'hover',
                              multiple: true,
                              value: 'id',
                              label: 'name',
                              children: 'children',
                            }" clearable />
                      </el-form-item>
                    </el-col>
                    <el-col :span="4" style="margin: 0 5px">
                      <el-form-item label=" " label-width="5px" :rules="{
                            required: true,
                            validator: first_num,
                            trigger: 'change',
                          }" :prop="'delivery_free.' + index + '.free_num'">
                        <div>包邮数量</div>
                        <el-input clearable @focus="Focus(delivery_free, 'free_num')"
                          @blur="Blur(delivery_free, 'free_num')" placeholder="包邮数量-满多少件包邮"
                          v-model="delivery_free.free_num" maxlength="7" show-word-limit></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="4" style="margin: 0 5px">
                      <el-form-item label=" " label-width="5px" :rules="{
                            required: true,
                            validator: first_price,
                            trigger: 'change',
                          }" :prop="'delivery_free.' + index + '.free_price'">
                        <div>包邮价格</div>
                        <el-input clearable @focus="Focus(delivery_free, 'free_price')"
                          @blur="Blur(delivery_free, 'free_price')" placeholder="包邮价格-满多少钱包邮(元)"
                          v-model="delivery_free.free_price" maxlength="7" show-word-limit></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col v-if="basicForm.delivery_free.length > 1" :span="2"
                      style="text-align: center;margin-top: 30px;">
                      <el-button type="danger" @click="delFreeWay(delivery_free)" icon="el-icon-minus"
                        circle></el-button>
                    </el-col>
                  </el-col>
                  <div style="margin-left: 36px;">
                    <el-button v-if="basicForm.delivery_free.length !== 0" @click="addFreeWay" type="primary"
                      icon="el-icon-plus">添加包邮地区</el-button>
                  </div>

                </el-col>
              </el-col>
              <el-col :span="24">
                <div class="informationTitleView">
                  <div class="leftBox" style="padding-left: 10px;">
                    <div class="leftborder"></div>
                    <div class="text">不配送地区</div>
                  </div>
                  <div class="right"></div>
                </div>
                <el-col :span="24">
                  <el-form-item label="不配送地区" prop="is_delivery_not">
                    <el-radio-group @change="is_delivery_notWay" v-model="basicForm.is_delivery_not">
                      <el-radio :label="0">关闭</el-radio>
                      <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-col v-if="basicForm.is_delivery_not !== 0" :span="20"
                    v-for="(delivery_not, index) in basicForm.delivery_not" :key="index" style="margin-left: 30px;">
                    <el-col :span="5" style="margin: 0 5px">
                      <el-form-item label=" " label-width="5px" :prop="'delivery_not.' + index + '.region_ids'" :rules="{
                            required: true,
                            validator: region_ids,
                            trigger: 'change',
                          }">
                        <div>地区</div>
                        <el-cascader @change="region_ids_jsonWay(delivery_not)" v-model="delivery_not.region_ids_json"
                          style="width: 100%" :options="regionList" collapse-tags :show-all-levels="false" :props="{
                              expandTrigger: 'hover',
                              multiple: true,
                              value: 'id',
                              label: 'name',
                              children: 'children',
                            }" clearable />
                      </el-form-item>
                    </el-col>
                  </el-col>

                </el-col>
              </el-col>
            </el-row>
          </el-form>
        </el-scrollbar>
        <div style="margin-top: 30px; text-align: center;">
          <el-button type="primary" @click="submitWay" style="width: 200px;">保存</el-button>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
  import {
    getFreightList,
    getFreightInfo,
    saveFreight,
    delFreight,
  } from "@/api/admin/freight";
  import {
    getRegionList
  } from "@/api/user/index";
  const tableTheadOption = {
    id: {
      label: "ID",
      field: "id",
    },
    created_at: {
      label: "创建时间",
      field: "created_at",
    },
    name: {
      label: "模板名称",
      field: "name",
    },
    is_delivery_free: {
      label: "开启包邮地区",
      field: "is_delivery_free",
    },
    is_delivery_not: {
      label: "开启不配送地区",
      field: "is_delivery_not",
    },
    weight: {
      label: "排序",
      field: "weight",
    },
    type: {
      label: "计费方式",
      field: "type",
    },
  };
  const allTableThead = [
    "id",
    "name",
    "weight",
    "created_at",
    "is_delivery_free",
    "is_delivery_not",
    "type"

  ];
  const defaultTableThead = [
    "id",
    "name",
    "weight",
    "created_at",
    "is_delivery_free",
    "is_delivery_not",
    "type"

  ];
  export default {
    watch: {
      checkboxTableThead(valArr) {
        this.tableThead = this.allTableThead.filter(
          (i) => valArr.indexOf(i) >= 0
        );
        this.tableKey = this.tableKey + 1;
      },
    },
    data() {
      return {
        id: "",
        loadings: false,
        regionList: [],
        basicForm: {
          id: "",
          name: "",
          type: 2,
          weight: 0,
          delivery_arrive: [{
            id: 0,
            region_ids: "",
            region_ids_json: [],
            first_num: "0",
            first_price: "0",
            renew_num: "0",
            renew_price: "0",
          }, ],
          is_delivery_free: 0,
          delivery_free: [],
          is_delivery_not: 0,
          delivery_not: [],
        },
        basicRules: {
          name: [{
            required: true,
            validator: (rule, value, callback) => {
              let req = /[^0-9a-zA-Z\u4e00-\u9fa5]/g;
              if (!value) {
                callback(new Error("请输入模板名称"));
              } else {
                if (req.test(value)) {
                  callback(new Error("模板名称中不能存在特殊字符"));
                } else {
                  callback();
                }
              }
            },
            trigger: "change",
          }, ],
        },
        region_ids: (rule, value, callback) => {
          if (value.length == 0) {
            callback(new Error("请选择区域"));
          } else {
            callback();
          }
        },
        region_idss: (rule, value, callback) => {
          callback();
        },
        first_num: (rule, value, callback) => {
          let req = /\D/g;
          if (value === "") {
            callback(new Error("请输入数量"));
          } else {
            if (req.test(value)) {
              callback(new Error("数量只能为数字,且只能是整数"));
            } else {
              callback();
            }
          }
        },
        first_price: (rule, value, callback) => {
          if (value === "") {
            callback(new Error("请输入价格"));
          } else {
            let req = /^\d+(\.\d{1,2})?$/;
            if (req.test(value)) {
              callback();
            } else {
              callback(new Error("只能输入数字,且只能保留两位小数"));
            }
          }
        },
        drawerfregit: false,
        // 动态显示表头默认表头
        tableTheadOptions: tableTheadOption,
        allTableThead: allTableThead,
        tableThead: defaultTableThead, // 默认表头
        checkboxTableThead: defaultTableThead, // 默认表头值
        tableKey: 1, // 为了保证table 每次都会重渲
        loading: false,
        total: 0,
        searchForm: {
          page: 1,
          pageSize: 10,
        },
        dataList: [],
      };
    },
    created() {
      this.getListWay();
      getRegionList({
        level: 2
      }).then((res) => {
        if (res.code !== 200 || res.status !== 1) {
          this.$messages.error(res.msg);
        }
        this.regionList = res.data;
      });
    },
    methods: {
      getInfoWay() {
        this.basicForm.id = this.backups.id;
        this.basicForm.name = this.backups.name;
        this.basicForm.type = Number(this.backups.type);
        this.basicForm.is_delivery_free = Number(this.backups.is_delivery_free);
        this.basicForm.is_delivery_not = Number(this.backups.is_delivery_not);
        this.basicForm.weight = this.backups.weight;
        this.basicForm.delivery_arrive = [];
        this.backups.delivery_arrive.forEach((item, index) => {
          this.basicForm.delivery_arrive.push({
            region_ids: "",
            region_ids_json: [],
            first_num: "0",
            first_price: "0",
            renew_num: "0",
            renew_price: "0",
          });
          this.basicForm.delivery_arrive[index].first_num = item.first_num;
          this.basicForm.delivery_arrive[index].first_price = item.first_price;
          this.basicForm.delivery_arrive[index].renew_num = item.renew_num;
          this.basicForm.delivery_arrive[index].renew_price = item.renew_price;
          if (item.regionList.length == 0) {
            this.basicForm.delivery_arrive[index].region_ids_json = [];
            this.basicForm.delivery_arrive[index].region_ids = "";
          } else {
            var arr = [];
            item.regionList.forEach((items, indexs) => {
              if (items.children && items.children.length !== 0) {
                items.children.forEach((itemss, indexss) => {
                  arr.push([items.id, itemss.id]);
                });
              }
            });
            this.basicForm.delivery_arrive[index].region_ids_json = arr;
            this.region_ids_jsonWay(this.basicForm.delivery_arrive[index]);
          }
        });

        this.basicForm.delivery_free = [];
        this.backups.delivery_free.forEach((item, index) => {
          this.basicForm.delivery_free.push({
            region_ids: "",
            region_ids_json: [],
            free_num: "0",
            free_price: "0",
          });
          this.basicForm.delivery_free[index].free_num = item.free_num;
          this.basicForm.delivery_free[index].free_price = item.free_price;
          if (item.regionList.length == 0) {
            this.basicForm.delivery_free[index].region_ids_json = [];
            this.basicForm.delivery_free[index].region_ids = "";
          } else {
            var arr = [];
            item.regionList.forEach((items, indexs) => {
              if (items.children && items.children.length !== 0) {
                items.children.forEach((itemss, indexss) => {
                  arr.push([items.id, itemss.id]);
                });
              }
            });
            this.basicForm.delivery_free[index].region_ids_json = arr;
            this.region_ids_jsonWay(this.basicForm.delivery_free[index]);
          }
        });

        this.basicForm.delivery_not = [];
        this.backups.delivery_not.forEach((item, index) => {
          this.basicForm.delivery_not.push({
            region_ids: "",
            region_ids_json: [],
          });

          if (item.regionList.length == 0) {
            this.basicForm.delivery_not[index].region_ids_json = [];
            this.basicForm.delivery_not[index].region_ids = "";
          } else {
            var arr = [];
            item.regionList.forEach((items, indexs) => {
              if (items.children && items.children.length !== 0) {
                items.children.forEach((itemss, indexss) => {
                  arr.push([items.id, itemss.id]);
                });
              }
            });
            this.basicForm.delivery_not[index].region_ids_json = arr;
            this.region_ids_jsonWay(this.basicForm.delivery_not[index]);
          }
        });
        this.loadings = false;
      },
      addDistributionWay() {
        this.basicForm.delivery_arrive.push({
          id: this.basicForm.delivery_arrive.length + "" + new Date().getTime(),
          region_ids: "",
          region_ids_json: [],
          first_num: "0",
          first_price: "0",
          renew_num: "0",
          renew_price: "0",
        });
      },
      delDistributionWay(row) {
        var arr = [];
        this.basicForm.delivery_arrive.forEach((item) => {
          if (item.id !== row.id) {
            arr.push(item);
          }
        });
        this.basicForm.delivery_arrive = arr;
      },
      is_delivery_freeWay(val) {
        if (val == 1) {
          if (this.basicForm.delivery_free.length == 0) {
            this.addFreeWay();
          }
        }
      },
      addFreeWay() {
        this.basicForm.delivery_free.push({
          id: this.basicForm.delivery_free.length + "" + new Date().getTime(),
          region_ids: "",
          region_ids_json: [],
          free_num: "0",
          free_price: "0",
        });
      },
      delFreeWay(row) {
        var arr = [];
        this.basicForm.delivery_free.forEach((item) => {
          if (item.id !== row.id) {
            arr.push(item);
          }
        });
        this.basicForm.delivery_free = arr;
      },
      is_delivery_notWay(val) {
        if (val == 1) {
          if (this.basicForm.delivery_not.length == 0) {
            this.basicForm.delivery_not.push({
              id: this.basicForm.delivery_not.length + "" + new Date().getTime(),
              region_ids: "",
              region_ids_json: [],
            });
          }
        }
      },
      region_ids_jsonWay(row) {
        var arr = [];
        if (row.region_ids_json.length !== 0) {
          row.region_ids_json.forEach((item) => {
            arr.push(item[1]);
          });
          row.region_ids = arr.toString();
        } else {
          row.region_ids = "";
        }
      },
      weightFocus(item) {
        if (item.weight == 0) {
          item.weight = "";
        }
      },
      weightBlur(item) {
        if (item.weight == "") {
          item.weight = 0;
        }
        if (Number(item.weight)) {
          item.weight = Number(item.weight);
        }
      },
      Focus(item, str) {
        if (item[str] == 0) {
          item[str] = "";
        }
      },
      Blur(item, str) {
        if (item[str] == "") {
          item[str] = 0;
        }
        if (Number(item[str])) {
          item[str] = Number(item[str]);
        }
      },
      submitWay() {
        this.$refs.basicForm.validate((valid) => {
          if (valid) {
            var obj = JSON.parse(JSON.stringify(this.basicForm));
            if (obj.delivery_arrive.length == 0) {
              obj.delivery_arrive = "";
            } else {
              obj.delivery_arrive.forEach((item) => {
                item.region_ids_json = JSON.stringify(item.region_ids_json);
              });
            }

            if (obj.is_delivery_free == 0) {
              obj.delivery_free = "";
            } else {
              obj.delivery_free.forEach((item) => {
                item.region_ids_json = JSON.stringify(item.region_ids_json);
              });
            }

            if (obj.is_delivery_not == 0) {
              obj.delivery_not = "";
            } else {
              obj.delivery_not.forEach((item) => {
                item.region_ids_json = JSON.stringify(item.region_ids_json);
              });
            }
            this.loadings = true;
            saveFreight(obj).then((res) => {
              this.loadings = false;
              if (res.code !== 200 || res.status !== 1) {
                this.$messages.error(res.msg);
                return;
              }
              this.drawerfregit = false
              this.getListWay();
            });
          } else {
            return false;
          }
        });
      },
      DialogsaveWays(){
        this.drawerfregit = true
        this.loading = false;
      },
      DialogsaveWay(id) {
        this.drawerfregit = true
          getFreightInfo({
            id: id
          }).then((res) => {
            if (res.code !== 200 || res.status !== 1) {
              this.$messages.error(res.msg);
              return;
            }
            this.backups = res.data;
            this.getInfoWay();
          });
      },
      //关闭运费弹窗
      closing_fregit() {
        this.drawerfregit = false
      },
      getListWay() {
        this.loading = true;
        getFreightList(this.searchForm).then((res) => {
          this.loading = false;
          if (res.code !== 200 || res.status !== 1) {
            this.loading = false;
            return this.$messages.error(res.msg);
          }
          this.dataList = res.data.list;
          this.total = res.data.total;
        });
      },
      resetting() {
        this.searchForm = {
          page: 1,
          pageSize: 10,
        };
        this.getListWay();
      },
      saveWay(url) {
        this.$router.push(url);
      },
    },
  };
</script>

<style>
</style>
